<?php
//php支持多行字符串
//单引号字符串，定界符是'
$s= 'I\'m a student\\\\teacher.\n'; //转义字符 (1)\'表示' (2)\\表示\
echo $s,"\n";
//双引号字符串，定界符是"，支持转义字符，支持变量解析
$s = "He say:\"I'm \141 student.\"\n"; //\141=8进制表示的字符a
echo $s;
var_dump(value:'Z'>'a');
//nowdoc类似于单引号，表示大块多行文本信息
    $s = <<<'XXXXYYYYZZZZ'
  <?php支持多行字符串
  //单引号字符串，定界符是'
  $s = 'I\'m a student\\\\teacher.\n'; //转义字符 (1)\'表示' (2)\\表示\
  echo $s,"\n";
  //双引号字符串，定界符是"，支持转义字符，支持变量解析
  $s = "He say:\"I'm \141 student.\"\n"; //\141=8进制表示的字符a
  echo $s;
  XXXXYYYYZZZZ;
echo $s,"--------OVER--------\n";


//字符串函数
//strlen 字符串的长度
$s="计算机0Aa";
echo  strlen($s),"\n";
//ord 首字节的编码
echo ord("0123"),"\n"; //48
//substr取子串
echo substr($s,9),"\n"; //0Aa
echo substr($s,6,5),"\n"; //机Aa
//Printf格式化输出
printf("My name is %s, I am %d years old.\n","zhangsan",18);
printf("[%d] [%5d] [%-5d] [%05d] [%x] [%04x]\n",26,26,26,26,26,26);
//用16进制显示字符串每一个字节的内容
for($i=0,$len=strlen($s);$i<$len;$i++){
    printf("%02x",ord($s[$i]));
}
echo "\n";

$sa="\xE8\xAE\xA1\xE7\xAE\x97\xE6\x9C\xBA\x30\x41\x61";
echo $sa,"\n";

//变量解析
$go="去";
$good="好";
echo "go的意思是：{$go}\n"; // go的意思是：去
echo "go的意思是：\$go\n"; // go的意思是：$go
echo "good的意思是：{$good}\n"; //good的意思是：好
echo "good的意思是：{$go}od\n"; //good的意思是：去od
echo "good去掉od是“{$go}”的意思\n"; //good去掉od是“去”的意思
$a=[243110101, 'name'=>'张三', 'age'=>18];
echo "学号：{$a[0]}，姓名：$a[name]，年龄：$a[age]\n";
echo "学号：{$a[0]}，姓名：{$a['name']}，年龄：{$a['age']}\n";

$a=123;
$b=111;
echo "$a + $b = ",$a+$b,"\n"; // 123 + 111 = 234
echo "$a + $b = $a+$b\n"; // 123 + 111 = 123+111
echo "$a + $b = {${!${''}=$a+$b}}\n"; //很神奇的东西 // 123 + 111 = 234




